package com.controller.lx;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.entity.Content;
import com.entity.Datetype;
import com.service.ServiceException;
import com.service.lx.DatetypeService;
import com.utils.Result;

@Controller
public class DatetypeController {
	@Autowired
	private DatetypeService datetypeService;
	
	/**
	 * 查询（分类）
	 * @param datetypeClassify
	 * @return
	 */
	@PostMapping("/datetype_classify_")
	@ResponseBody
	public List<Datetype> finddatetypeClassifyandDatetypeIfopen1(@RequestParam("datetypeClassify") String datetypeClassify){
		return datetypeService.findDatetypeClassifyandDatetypeIfopen1(datetypeClassify);
	}
	
	/**
	 * 查询（分类）
	 * @param datetypeClassify
	 * @return
	 */
	@PostMapping("/datetype_classifyall_")
	@ResponseBody
	public List<Datetype> finddatetypeClassifyandDatetype(@RequestParam("datetypeClassify") String datetypeClassify){
		return datetypeService.findDatetypeClassifyandDatetype(datetypeClassify);
	}
	
	/**
	 * 逻辑删除
	 * @param Id
	 * @throws ServiceException
	 */
	@DeleteMapping("/datetype_ifdelete_")
	@ResponseBody
	public Result UpdateIfdelete(Long Id){
		datetypeService.UpdateUserIfdelete(Id);
		return Result.SUCCESS;
	}

	/**
	 * 批量删除
	 * @param qaIds
	 */
	@PostMapping("/datetype_delete_arr_")
	@ResponseBody
	public Result deletBatchRoles(@RequestBody JSONArray Ids) {
		datetypeService.deletArrIfDelete(JSONObject.parseArray(Ids.toString(), Long.class));
		return Result.SUCCESS;
	}

	/**
	 * 添加/修改
	 * @param datetype
	 * @throws ServiceException
	 */
	@PostMapping("/datetype_addandupdate_")
	@ResponseBody
	public Result addAndUpdate(@RequestBody Datetype datetype){
		datetypeService.addAndUpdateDatetype(datetype);
		return Result.SUCCESS;
	}
}
